<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>编写一个简单计算器</title>
<style>
	div{
		margin: auto;
		text-align: center;
	}	
</style>
<script>
	function jisuan(e){
        var  inouts = document.getElementsByTagName("input");
		var one = parseInt(input[0].value);
		var one = parseInt(input[1].value);

		x = e.target.value;

		switch (x) {
			case "+": inputs[2].value = one + two; break;
			case "-": inputs[2].value = one - two; break;
			case "*": inputs[2].value = one * two; break;
			case "/": inputs[2].value = one / two; break;
			default:inputs[2].value = 0;
		}
	}
</script>
</head>

<body>
<form action="">
<div>
	第一个数：<input type="text">
	第二个数：<input type="text">
	结果：<input type="text"><br>
	<input type="button" value="+" onclick="jisuan();">
	<input type="button" value="-" onclick="jisuan();">
	<input type="button" value="*" onclick="jisuan();">
	<input type="button" value="/" onclick="jisuan();">
</div>
</form>
</body>
</html>
